// 网络请求工具
const http = (url, data, callback) => {
    wx.request({
        url: url,
        data: data,
        header: {
            'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'POST',
        success(res) {
            console.log(res)
            if (res.data.code == 200 || res.data.code == 404) {
                callback(res)
            } else {
                // 请求异常,用户消息提示
                wx.showModal({
                    title: '消息提示',
                    content: res.data.msg,
                    showCancel: false
                })
            }
        },
        fail(res) {
            console.log(res)
        },
        complete() {
            wx.hideLoading();
        }
    })
}

module.exports = {
    http: http
}